package com.sto.stoapp.dataprocess;

import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

import com.sto.stoapp.db.constant.StoKailiAftermarketConstant;
import com.sto.stoapp.log.ExceptionLog;
import com.sto.stoapp.util.UnifiedStaticType;

public class ProcessAftermarket {

	public void insertAftermarketData(SQLiteDatabase db) {
		String kailiData = "杭州售后寄件地址:\r\n杭州市滨江区江南大道 288号康恩贝大厦B座12F\r\n电话:"
				+ "0571-87012038   0571-87012638\r\n上海售后寄件地址:\r\n上海申通总部(原地址) 国际部旁\r\n电话:15221840984"
				+ "     021-39206611\r\n广州售后地址:\r\n广州申通中转部IT部\r\n电话:13660746750\r\n成都售后地址:\r\n成都申通IT部办公室\r\n电话:13980509255\r\n";
		insert(kailiData, db);
	}

	/**
	 * 插入单条数据
	 * 
	 * @param entity
	 * @return
	 */
	private boolean insert(String info, SQLiteDatabase db) {
		synchronized (UnifiedStaticType.DATABASE_SYNCHRONIZED) {
			long res = -1;

			try {
				ContentValues values = new ContentValues();
				values.put(StoKailiAftermarketConstant.KAILI_AFTERMARKET_INFO,
						info);
				res = db.insert(
						StoKailiAftermarketConstant.KAILI_AFTERMARKET_TABLE,
						null, values);
				if (res > 0) {
					Log.d("插入一条凯立售后信息", "成功");
				} else {
					Log.d("插入一条凯立售后信息", "失败");
				}
			} catch (Exception e) {
				e.printStackTrace();
				ExceptionLog.writeLog("insert", e.getMessage());
			}
			return res > 0 ? true : false;
		}
	}
}
